const gulp = require("gulp");
const uglify = require("gulp-uglify");
const cleanCSS = require('gulp-clean-css');
const imagemin = require("gulp-imagemin")
var sass = require("gulp-sass");
sass.compiler = require('node-sass');
const babel = require("gulp-babel");

gulp.task("html-build",()=>{
    return gulp.src("./src/*.html").pipe(gulp.dest("./dist"))
})
gulp.task("scripts-build",()=>{
    return gulp.src("./src/js/*.js")
    .pipe(babel({
        presets:['@babel/env']
    }))
    .pipe(uglify())
    .pipe(gulp.dest("./dist/js"))
})
gulp.task("stylesheet-build",()=>{
    return gulp.src("./src/css/*.css")
    .pipe(sass())
    .pipe(cleanCSS({debug : true},(details) => {
        console.log(`${details.name} : ${details.stats.orginalSize}`);
        console.log(`${details.name} : ${details.stats.minifiesSize}`);}))
    .pipe(gulp.dest("./dist/css"))
})
gulp.task("picture-build",()=>{
    return gulp.src("./src/img/**/*").pipe(imagemin()).pipe(gulp.dest("./dist/img"))
})

gulp.task("build",["html-build","scripts-build","stylesheet-build","picture-build"])